// Copyright (c) 2023 CHANGLEI. All rights reserved.

part of 'arith.dart';

/// Created by changlei on 2023/6/7.
///
/// 圆括号
enum Curve with Describable implements Symbols {
  /// 左括号
  left,

  /// 右括号
  right;

  @override
  String toDescribe([bool isTight = false]) {
    return switch (this) {
      left => r'(',
      right => r')',
    };
  }

  /// 解析
  static Curve? maybeOf(String s) => values.where((element) => element.toString() == s).singleOrNull;

  /// 解析
  static Curve of(String s) => ArgumentError.checkNotNull(maybeOf(s));

  /// 增加边界
  static Expression wrap(Arith arith) => left + arith + right;
}
